
<template>
    <div>
      <eagle-list :tabData="tabData" @initActive="_initActive" @bindData="bindData" :filterParams="filterParams"
        :filterParamsDefaul="filterParamsDefaul" 
        :filterTab="filterTab" 
        allowSearch placeholder="请输入文件名称搜索"
        :_conditions="conditions" 
        _conditions_search_name="CompanyName"
        ref="eaglelist">
  
        <eagle-cell style="margin-top: 10px" class="card" v-for="(item, index) in list" :key="index">
          <div class="warn_item">
            <div @click="toFKCompanyDetail(item)">
              <div class="warn_header">
                <div>{{ item.CompanyName }}</div>
              </div>
              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                  <img src="@/assets/Images/AppIcon/icon_list_enterprise.png" alt="" class="icon" />{{ item.ParentCompanyName
                  }}
                </van-col>
              </van-row>
            </div>
            <van-divider />
            <div class="item_tool">
              <div class="item_tool_item" @click="to_edit_FKCompanyDetail(item)">
                <img src="@/assets/Images/AppIcon/icon_list_edit.png" alt="" class="icon" />
                <div class="mr-10">编辑</div>
              </div>
              <div class="item_tool_item" @click="doEvaluated(item)">
                <img src="@/assets/Images/AppIcon/icon_list_source.png" alt="" class="icon" />
                <div class="mr-10">{{item.IsCompleteEvaluation?'未评估':'评估'}}</div>
              </div>
            </div>
          </div>
        </eagle-cell>
  
      </eagle-list>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        active: 0,
        list: [],
        filterTab: true,
        // filterParamsDefaul: [{ name: "Status", value: "10" }],
        filterParamsDefaul: [],
        filterParams: [
          {
            name: "Status",
            title: "状态",
            originTitle: "状态",
            dataType: "int",
            data: [
              { text: "不限", value: "" },
              { text: "现行", value: "10" },
              { text: "废止", value: "-1" },
            ],
          },
          {
            name: "AppointmentType",
            title: "类别",
            originTitle: "类别",
            dataType: "string",
            data: [
              { text: "不限", value: "" },
              { text: "安全生产领导小组认命", value: "A" },
              { text: "安全生产管理人员认命", value: "B" },
            ],
          },
        ],
        tabData: [
          {
            title: "安全管理机构人员任命",
            url: "/UserCompany/GetPageData",
            isPage: true,
            params: {
              dataType: "dangerLevelOrgCompanyList",
            },
          },
          // {
          //   title: "任命书文件",
          //   url: "/ProjectEntrustedOnlineDoc/GetPageData",
          //   isPage: true,
          //   params: {
          //     dataType: "List",
          //     menuNo: "0201",
          //   },
          // },
        ],
        option1: [
          { text: "不限", value: "" },
          { text: "现行", value: "10" },
          { text: "废止", value: "-1" },
        ],
        option2: [
          { text: "不限", value: "" },
          { text: "安全生产领导小组认命", value: "A" },
          { text: "安全生产管理人员认命", value: "B" },
        ],
        riskPoints: [],
        CompanyNo:this.$route.query.CompanyNo,
        conditions:''
      };
    },
    created() {
    
        this.conditions='[{"IsTemp":false,"Name":"CompanyNo","Value":"'+this.CompanyNo+'"}]'
        this.$store.state.title=this.$route.query.CompanyName
        this.$axios.get("/UserCompany/GetRiskPoints", {}).then(res => {
            this.riskPoints = res.data
      })
    },
    mounted() {
  
    },
    methods: {
        toFKCompanyDetail(item){
            this.$router.push('FKCompanyInfoDetail?CompanyCode='+item.CompanyCode+"&CompanyName="+item.CompanyName+"&Score="+item.Score+"&InherentLevelValue="+item.InherentLevelValue+"&DangerLevel="+item.DangerLevel)
        },
        to_edit_FKCompanyDetail(item){
          this.$router.push("/BaseInfo?CompanyCode=" + item.CompanyCode+"&type="+'DangerLevel');
        },
        doEvaluated(item){
          let message=!item.IsCompleteEvaluation?'确定要进行评估吗':'确定要取消评估吗'
          this.$dialog
                .confirm({
                    title: "询问",
                    message
                })
                .then(() => {
                  // "+bean.getID()+"&isCompleteEvaluation="+!bean.isCompleteEvaluation()
                    this.$axios.post("/DangerEnterprise/IsEvaluated?id="+item.ID+"&isCompleteEvaluation="+!item.IsCompleteEvaluation).then(res=>{
                      location.reload()
                    })
                    
                    
                })
                .catch(() => {
  
                });
          
        },
      getDeleteTitle(DirectDelete) {
        if (DirectDelete > 0) {
          return "删除该企业"
        } else {
          return "申请删除该企业"
        }
      },
      goToDetail(item) {
        this.$router.push({
          path: "/BaseInfo",
          query: { CompanyCode: item.CompanyCode },
        });
      },
      
      _initActive(active) {
        if (active === 0) {
          this.$refs.eaglelist.changefilterTab(true);
        }
        if (active === 1) {
          this.$refs.eaglelist.changefilterTab(false);
        }
        this.active = active;
      },
      bindData(data) {
        this.list = data;
        console.log(this.list)
      },
      goToEdit(item) {
        this.$router.push({
          path: "/SiteappointmentEdit",
          // name: "SiteappointmentEdit",
          query: { id: item.ID },
        });
      },
      // 新增企业
      add() {
        this.$router.push({
          // name: "SiteappointmentAdd",
          path: "/SubUnitAdd",
          query: { id: 0 },
        });
      },
      /**
       * 删除企业
       * @param {*} item 
       */
      del(item) {
        const _this = this;
        if (item.DirectDelete > 0) {
  
          this.$dialog
            .confirm({
              title: "询问",
              message: "您确定要删除该企业吗？",
            })
            .then(() => {
              this.$axios
                .get("/UserCompany/DeleteCompanyNo", { params: { id: item.ID } })
                .then((res) => {
                  _this.$toast.success("删除企业成功");
                  setTimeout(() => {
                    _this.$refs.eaglelist.getList();
                  }, 300);
                })
                .catch((err) => {
                  console.log("err", err);
                });
            })
            .catch(() => {
              // on cancel
            });
        } else {
  
        }
  
      },
      goToInLower(){
        this.$dialog.alert({
          title: "询问",
          message: "程序员开发中",
        })
      },
      //获取 关键风险的 数据
      getRiskPoints(RiskPoint) {
        var value = ""
        if (this.riskPoints) {
          this.riskPoints.forEach(element => {
            if ((RiskPoint & element.ID) > 0) {
              let temp = element.Name + "√"
              console.log(temp)
  
              value = value + temp + "  "
            }
  
          });
        }
        return value
      }
    }
  };
  </script>
  
  <style lang="less" scoped>
  .risk {
    background-color: #e8f1f8;
  
    .info_search {
      padding: 10px;
      border-radius: 5px !important;
  
      .van-field__control {
        background-color: #ffffff !important;
      }
    }
  }
  
  .warn_item {
    /*margin-bottom: 10px;*/
    // padding: 10px 0 10px 10px;
    border-radius: 5px;
    position: relative;
  }
  
  .warn_header {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 10px;
  
    .warn_tag {
      position: absolute;
      right: 0;
      top: 0;
      border-radius: 26.64rem 0 0 26.64rem;
    }
  }
  
  .dep_sort {
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
  
  
  .item_tool {
    display: flex;
    justify-content: space-between;
  
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
  
  .item_tool_item {
    display: flex;
    align-items: center;
  }
  </style>
  